package com.atguigu.test.service.impl;

import com.atguigu.test.service.DogService;
import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author zp
 * @version 1.0
 * @description: TODO
 * @date 2022/9/6 19:36
 */
@Slf4j
public class DogInvocationHandler implements InvocationHandler {
    private DogService dogService;

    public DogInvocationHandler(DogService dogService){
        this.dogService = dogService;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if("setName".equals(method.getName())){
            args[0] = "怪怪的"+args[0];
        }
        method.invoke(dogService,args);
        return proxy;
    }
}
